<template>
  <div>
    <van-nav-bar title="文章详情" fixed placeholder left-arrow />

    <div class="big-box">
      <h2>{{ detail.title }}</h2>
      <!-- 作者信息区域 -->
      <div class="aut-box">
        <van-image fit="cover" round :src="detail.aut_photo"></van-image>
        <div class="info-box">
          <div class="name">{{ detail.aut_name }}</div>
          <div class="time">{{ detail.pubdate | relvTime }}</div>
        </div>
        <van-button size="small" type="info" round icon="plus">关注</van-button>
      </div>

      <!-- 文章内容区域 -->
      <div class="content" v-html="detail.content"></div>
    </div>
  </div>
</template>

<script>
import { articleDetailAPI } from '@/api/article'
export default {
  data () {
    return {
      detail: {}
    }
  },



  async created () {
    const res = await articleDetailAPI(this.$route.query.id)
    // console.log(res)
    this.detail = res.data
  }
}
</script>

<style lang="less" scoped>
.big-box {
  padding: 0 20px;
  h2 {
    font-size: 20px;
    margin: 20px 0;
  }
  .aut-box {
    display: flex;
    align-items: center;
    margin-bottom: 20px;
    .van-image {
      width: 80px;
      height: 80px;
      margin-right: 10px;
    }
    .info-box {
      flex: 1;
      .time {
        color: gray;
        font-size: 12px;
        margin-top: 10px;
      }
    }
  }
  //content
  .content {
    ::v-deep {
      p {
        word-break: break-all;
      }

      img {
        width: 100%;
      }

      pre {
        background-color: #000;
        color: lightgray;
        overflow: auto;
        width: 100%;
      }
    }
  }
}
</style>